package com.service.consumer;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableDiscoveryClient
//@EnableHystrix  @EnableCircuitBreaker 这两个注解的作用差不多，都能实现熔断降级
@EnableCircuitBreaker
@EnableFeignClients
public class SpringServiceConsumer1Application {

	public static void main(String[] args) {
		SpringApplication.run(SpringServiceConsumer1Application.class, args);
	}
	
	@Bean
	//表明这个 restTemplate 开启负载均衡功能
	@LoadBalanced
	RestTemplate restTemplate(){
		return new RestTemplate();
	}

}
